import request from "../utils/request"
// const baseURl = 'http://112.193.235.134:13902'
// const baseURl = "http://139.9.159.254:8089"
// export const baseURl = "http://10.1.35.53:1001";
// const baseURl = "http://139.9.159.254:1001";

// export const proxyURl = "http://139.9.159.254:1001"; // 1005 上线
// export const proxyURl = "http://10.10.30.47:1001"
// export const proxyURl = "http://192.168.43.32:1001"
// export const proxyURl = "https://31fb662539yq.vicp.fun"
export const proxyURl = "http://1.94.111.92:1001"
// const proURl = "http://1.94.111.92:1001/api"
const proURl = "http://1.94.111.92:1002/api"

export const baseURl = process.env.NODE_ENV === "development" ? "api" : proURl
// export const baseURl = proxyURl
export const fetchData = () => {
  return request({
    url: "./table.json",
    method: "get"
  })
}

export const getOnlneList = (data: any) => {
  return request({
    url: `${baseURl}/deviceRegister/getDeviceList`,
    method: "post",
    data
  })
}

// 查询实验管理列表
export function appTestList(data: any) {
  return request({
    url: `${baseURl}/testManage/appTestList`,
    method: "POST",
    data
  })
}

// 线损分析图
export function getLineChart(data: any) {
  return request({
    url: `${baseURl}/lineChart/getLineChart`,
    method: "post",
    data
  })
}

// 获取验证图片
export function getCodePicture() {
  return request({
    url: `${baseURl}/captcha.jpg`,
    method: "get",
    responseType: "blob"
  })
}

// 登录
export function loginFn(data: any) {
  return request({
    url: `${baseURl}/app/appLogin`,
    method: "POST",
    data
  })
}

// 终端管理查看详情
export const getDevice = (params: any) => {
  return request({
    url: `${baseURl}/terminalDevice/getDevice`,
    method: "get",
    params
  })
}

// 查询实验管理新增
export function createDevice(data: any) {
  return request({
    url: `${baseURl}/terminalDevice/createDevice`,
    method: "POST",
    data
  })
}

// 终端管理查看删除
export const deleteDevice = (params: any) => {
  return request({
    url: `${baseURl}/terminalDevice/deleteDevice`,
    method: "get",
    params
  })
}

// 查询实验管理新增
export function editDevice(data: any) {
  return request({
    url: `${baseURl}/terminalDevice/editDevice`,
    method: "POST",
    data
  })
}

// 终止正在进行中的实验
export function stopTest(params: any) {
  return request({
    url: `${baseURl}/testManage/stopTest`,
    method: "get",
    params
  })
}

// 电能导入
export function electricExcel(data: any) {
  return request({
    url: `${baseURl}/import/electricExcel`,
    method: "POST",
    data
  })
}
// 台区列表
export function newDistrictGetDistrictList(data: any) {
  return request({
    url: `${baseURl}/newDistrict/getDistrictList`,
    method: "POST",
    data
  })
}
// 配置数据导入
export function configureImportExcel(data: any) {
  return request({
    url: `${baseURl}/newDistrict/importDeviceUserExcel`,
    method: "POST",
    data
  })
}
// 配置用户数据导入
export function newDistrictImportUserData(data: any) {
  return request({
    url: `${baseURl}/newDistrict/importUserData`,
    method: "POST",
    data
  })
}
// 配置数据导入后的列表
export function newDistrictGetDeviceUserList(data: any) {
  return request({
    url: `${baseURl}/newDistrict/getDeviceUserList`,
    method: "POST",
    data
  })
}

// 查询时间段
export function getLineChartQueryTime(testNo: any) {
  return request({
    url: `${baseURl}/lineChart/getLineChartQueryTime?testNo=${testNo}`,
    method: "get"
  })
}

// 获取机构列表树
export const orgList = () => {
  return request({
    url: `${baseURl}/sys/org/getTree`,
    method: "get"
  })
}

// 获取机构列表
export const orgList2 = () => {
  return request({
    url: `${baseURl}/sys/org/list`,
    method: "get"
  })
}

// 获取用户列表
export const userList = (data: any) => {
  return request({
    url: `${baseURl}/sys/user/list`,
    method: "post",
    data
  })
}

// 获取Tcp列表
export const TcpList = (data: any) => {
  return false
  // return request({
  //   url: `${baseURl}/tcpData/list`,
  //   method: "post",
  //   data,
  // });
}

// 获取Tpc折线图
export const TcpChart = (data: any) => {
  return request({
    url: `${baseURl}/tcpData/getTcpLineChart`,
    method: "post",
    data
  })
}

// 新增机构
export const addOrg = (data: any) => {
  return request({
    url: `${baseURl}/sys/org/save`,
    method: "post",
    data
  })
}

// 删除机构节点
export const delOrg = (data: any) => {
  return request({
    url: `${baseURl}/sys/org/remove`,
    method: "post",
    data
  })
}

// 编辑机构节点
export const editOrg = (data: any) => {
  return request({
    url: `${baseURl}/sys/org/update`,
    method: "post",
    data
  })
}

// 新增用户
export const addUser = (data: any) => {
  return request({
    url: `${baseURl}/sys/user/save`,
    method: "post",
    data
  })
}

// 删除用户
export const delUser = (data: any) => {
  return request({
    url: `${baseURl}/sys/user/remove`,
    method: "post",
    data
  })
}

// 编辑用户
export const editUser = (data: any) => {
  return request({
    url: `${baseURl}/sys/user/update`,
    method: "post",
    data
  })
}



// 获取角色列表
export const roleList = (data: any) => {
  return request({
    url: `${baseURl}/sys/role/list`,
    method: "post",
    data
  })
}
// 新增角色
export const addRole = (data: any) => {
  return request({
    url: `${baseURl}/sys/role/save`,
    method: "post",
    data
  })
}
// 编辑角色
export const editRole = (data: any) => {
  return request({
    url: `${baseURl}/sys/role/update`,
    method: "post",
    data
  })
}
// 删除角色
export const deleteRole = (data: any) => {
  return request({
    url: `${baseURl}/sys/role/remove`,
    method: "post",
    data
  })
}

// 重置密码
export const resetPassword = (data: any) => {
  return request({
    url: `${baseURl}/sys/user/reset`,
    method: "post",
    data
  })
}

//  2023-05-16 新版本 newwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
export const getNewDataList = (data: any) => {
  return request({
    url: `${baseURl}/tcpData/getNewDatalist`,
    method: "post",
    data
  })
}

export const getNewLineLossAnalysisList = (data: any) => {
  return request({
    url: `${baseURl}/lineChart/getLineLossAnalysisList`,
    method: "post",
    data
  })
}

export const getNewDeviceList = (data: any) => {
  return request({
    url: `${baseURl}/district/getDeviceList`,
    method: "post",
    data
  })
}

// 详情
export const getNewDeviceHistoryData = (data: any) => {
  return request({
    url: `${baseURl}/lineChart/getDeviceHistoryData`,
    method: "post",
    data
  })
}
// 创建台区
export const createNewDistrict = (data: any) => {
  return request({
    url: `${baseURl}/district/createDistrict`,
    method: "post",
    data
  })
}
// 修改台区
export const editNewDistrict = (data: any) => {
  return request({
    url: `${baseURl}/district/updateDistrict`,
    method: "post",
    data
  })
}
// 删除台区
export const deleteNewDistrict = (districtId: any) => {
  return request({
    url: `${baseURl}/district/deleteDistrict?districtId=${districtId}`,
    method: "get"
  })
}

// 文件导入列表
export const getNewImportFileList = (data: any) => {
  return request({
    url: `${baseURl}/file/getImportFileList`,
    method: "post",
    data
  })
}

export const getNewLineChart = (data: any) => {
  return request({
    url: `${baseURl}/lineChart/getNewLineChart`,
    method: "post",
    data
  })
}

export const uploadNewFile = (data: any) => {
  return request({
    url: `${baseURl}/file/uploadFile`,
    method: "post",
    data,
    headers: {
      "Content-type": "multipart/form-data"
    }
  })
}
export const getNewTree = (districtId: number | string) => {
  return request({
    url: `${baseURl}/district/getTree?districtId=${districtId}`,
    method: "get"
  })
}

export const exportData = ({ deviceNo, dateTime }) => {
  return request({
    url: `${baseURl}/export/data?deviceNo=${deviceNo}&dateTime=${dateTime}`,
    method: "get",
    responseType: "blob"
  })
}

export const getDeviceCalibrationList = (data) => {
  return request({
    url: `${baseURl}/deviceCalibration/getDeviceCalibrationList`,
    method: "post",
    data
  })
}

export const startCalibration = (data) => {
  return request({
    url: `${baseURl}/deviceCalibration/calibration`,
    method: "post",
    data
  })
}

export const getDeviceCalibrationResult = (data) => {
  return request({
    url: `${baseURl}/deviceCalibration/getDeviceCalibrationResult`,
    method: "post",
    data
  })
}

export const getDeviceCalibrationCheck = (data) => {
  return request({
    url: `${baseURl}/deviceCalibration/check`,
    method: "post",
    data
  })
}

export const getDeviceCalibrationCheckResult = (data) => {
  return request({
    url: `${baseURl}/deviceCalibration/getDeviceCalibrationCheckResult`,
    method: "post",
    data
  })
}

export const getDeviceCalibrationGetStep = () => {
  return request({
    url: `${baseURl}/deviceCalibration/getStep`,
    method: "get"
  })
}

export const getDeviceCalibrationCountRatio = (data) => {
  return request({
    url: `${baseURl}/deviceCalibration/countRatio`,
    method: "post",
    data
  })
}
export const getDeviceCalibrationDetailList = (data) => {
  return request({
    url: `${baseURl}/deviceCalibration/getDeviceCalibrationDetailList`,
    method: "post",
    data
  })
}
export const updateCalibrationFactor = (data) => {
  return request({
    url: `${baseURl}/deviceCalibration/updateCalibrationFactor`,
    method: "post",
    data
  })
}
